[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: BNF-like grammar specified DIRECTLY in Ruby

Eric Mahurin

4/16/2005 2:23:00 PM

Would it be better to put it on rubyforge after renaming?

Also, is it best rubygems? Is this the ruby equivalent of cpan
for perl?

--- Jamis Buck <jamis@37signals.com> wrote:
> Very nice! One quibble: any chance you could change the name?
>
> http://rubyforge.org/proje...
>
> :) Might get confusing if someone wants to install both libs.
>
> - Jamis
>
> On Apr 15, 2005, at 10:25 PM, Eric Mahurin wrote:
>
> > Here is my first contribution to Ruby:
> >
> > http://raa.ruby-lang.org/proje...
> >
> > There is still plenty missing in here and it is a work in
> > progress, but I think it is ready for some of you to try it
> out
> > if you like it.
> >
> > To get an idea of what this is, there is a simple
> expression
> > evaluator example below. This is pure Ruby code - no yacc
> type
> > compiling necessary. That's what I love about it.
> >
> > Eric
> >
> >
> > #!/usr/bin/ruby -d
> >
> > require "syntax"
> >
> > NULL = Syntax::NULL
> > INF = +1.0/0
> > LOOP0 = (0..INF)
> > LOOP1 = (1..INF)
> >
> > int = (("0".."9")*LOOP1).qualify { |m| m.to_s.to_i }
> >
> > number = (
> > int +
> > (("."+int)|NULL) +
> > ((("e"|"E")+("+"|"-"|NULL)+int)|NULL)
> > ).qualify { |m|
> > if (m.length>1)
> > m.to_s.to_f
> > else
> > m[0]
> > end
> > }
> >
> > ws = ((" "|"\t"|"\n")*LOOP0).qualify { TRUE } # skipped
> with
> > TRUE
> >
> > expr = Syntax::Pass.new # need to predefine object for
> > recursion
> >
> > atom =
> > (number+ws).qualify{|m|m[0]} |
> > ("(" + expr + ")" + ws).qualify{|m|m[1]}
> >
> > term = (
> > atom + ( ("*"|"/"|"%") + ws + atom )*LOOP0
> > ).qualify { |m|
> > product = m[0]
> > m[1].each { |m|
> > case m[0]
> > when "*" then product *= m[1]
> > when "/" then product /= m[1]
> > when "%" then product %= m[1]
> > end
> > }
> > product
> > }
> >
> > expr << (
> > ws + term + ( ("+"|"-") + ws + term )*LOOP0
> > ).qualify { |m|
> > sum = m[0]
> > m[1].each { |m|
> > case m[0]
> > when "+" then sum += m[1]
> > when "-" then sum -= m[1]
> > end
> > }
> > sum
> > }
> >
> > while (gets)
> > p(expr===RandomAccessStream.new($_))
> > end




__________________________________
Do you Yahoo!?
Plan great trips with Yahoo! Travel: Now over 17,000 guides!
http://travel.yahoo.com/p-t...


2 Answers

Jamis Buck

4/16/2005 3:55:00 PM

0

On Apr 16, 2005, at 8:23 AM, Eric Mahurin wrote:

> Would it be better to put it on rubyforge after renaming?
>

That's not necessary, but it's nice if you need a CVS repository, or a
home page, or a wiki for your project. It also gives you bug and
feature request tracking, mailing lists, forums, and more. If any of
that sounds appealing, you may want to apply for a new project there.
If you have those things all hosted elsewhere, or you don't want/need
them, then you probably won't gain anything by a RubyForge project
(except, perhaps, better project visibility).

> Also, is it best rubygems? Is this the ruby equivalent of cpan
> for perl?

Currently RubyGems is the de facto standard for Ruby libraries. There
really isn't a CPAN equivalent for Ruby, yet--we've got RAA and
RubyForge, with RubyGems as the package manager. (Another nice thing
about RubyForge--when you add a gem file to your project file list, it
will automatically be added to the RubyGems package list.)

- Jamis

>
> --- Jamis Buck <jamis@37signals.com> wrote:
>> Very nice! One quibble: any chance you could change the name?
>>
>> http://rubyforge.org/proje...
>>
>> :) Might get confusing if someone wants to install both libs.
>>
>> - Jamis
>>
>> On Apr 15, 2005, at 10:25 PM, Eric Mahurin wrote:
>>
>>> Here is my first contribution to Ruby:
>>>
>>> http://raa.ruby-lang.org/proje...
>>>
>>> There is still plenty missing in here and it is a work in
>>> progress, but I think it is ready for some of you to try it
>> out
>>> if you like it.
>>>
>>> To get an idea of what this is, there is a simple
>> expression
>>> evaluator example below. This is pure Ruby code - no yacc
>> type
>>> compiling necessary. That's what I love about it.
>>>
>>> Eric
>>>
>>>
>>> #!/usr/bin/ruby -d
>>>
>>> require "syntax"
>>>
>>> NULL = Syntax::NULL
>>> INF = +1.0/0
>>> LOOP0 = (0..INF)
>>> LOOP1 = (1..INF)
>>>
>>> int = (("0".."9")*LOOP1).qualify { |m| m.to_s.to_i }
>>>
>>> number = (
>>> int +
>>> (("."+int)|NULL) +
>>> ((("e"|"E")+("+"|"-"|NULL)+int)|NULL)
>>> ).qualify { |m|
>>> if (m.length>1)
>>> m.to_s.to_f
>>> else
>>> m[0]
>>> end
>>> }
>>>
>>> ws = ((" "|"\t"|"\n")*LOOP0).qualify { TRUE } # skipped
>> with
>>> TRUE
>>>
>>> expr = Syntax::Pass.new # need to predefine object for
>>> recursion
>>>
>>> atom =
>>> (number+ws).qualify{|m|m[0]} |
>>> ("(" + expr + ")" + ws).qualify{|m|m[1]}
>>>
>>> term = (
>>> atom + ( ("*"|"/"|"%") + ws + atom )*LOOP0
>>> ).qualify { |m|
>>> product = m[0]
>>> m[1].each { |m|
>>> case m[0]
>>> when "*" then product *= m[1]
>>> when "/" then product /= m[1]
>>> when "%" then product %= m[1]
>>> end
>>> }
>>> product
>>> }
>>>
>>> expr << (
>>> ws + term + ( ("+"|"-") + ws + term )*LOOP0
>>> ).qualify { |m|
>>> sum = m[0]
>>> m[1].each { |m|
>>> case m[0]
>>> when "+" then sum += m[1]
>>> when "-" then sum -= m[1]
>>> end
>>> }
>>> sum
>>> }
>>>
>>> while (gets)
>>> p(expr===RandomAccessStream.new($_))
>>> end
>
>
>
>
> __________________________________
> Do you Yahoo!?
> Plan great trips with Yahoo! Travel: Now over 17,000 guides!
> http://travel.yahoo.com/p-t...
>



Des Higgins

4/10/2010 4:17:00 PM

0

On Apr 10, 5:11 pm, Vernon Pugh <dazzhigg...@hotmail.com> wrote:
> On Apr 10, 4:26 pm, An Mac Tíre Bán <rayh(removespamblocker>@iol.ie
> wrote:
>
>
>
> > On Sat, 10 Apr 2010 07:01:21 -0700 (PDT), Vernon Pugh <dazzhigg...@hotmail.com>
> > wrote:
>
> > >On Apr 10, 5:54 am, "Ray OHara" <raymond-oh...@hotmail.com> wrote:
> > >> "Romulus Mac An tSagairt" <victorburgu...@gmail.com> wrote in messagenews:3d839a5b-5026-43de-963d-7eee969ff8e2@u34g2000yqu.googlegroups.com...
> > >> On Apr 8, 4:05 pm, An Mac Tíre Bán <rayh(removespamblocker>@iol.ie
> > >> wrote:
>
> > >> > On Thu, 8 Apr 2010 07:05:59 -0700 (PDT), Romulus Mac An tSagairt
>
> > >> > <victorburgu...@gmail.com> wrote:
> > >> > >On Apr 8, 2:36 pm, An Mac Tíre Bán <rayh(removespamblocker>@iol.ie
> > >> > >wrote:
> > >> > >> On Wed, 7 Apr 2010 23:23:52 -0700 (PDT), Cormac
> > >> > >> <cormac.brada...@hotmail.com>
> > >> > >> wrote:
>
> > >> > >> >Racists frequently post on Usenet about the "white race". I have never
> > >> > >> >been able to discover what this means.
>
> > >> > >> >Take the case of Eugene Terre'Blanche the "white" racist who was
> > >> > >> >recently murdered in South Africa. It is clear that his skin colour
> > >> > >> >was yellow.
>
> > >> > >>http://en.wikipedia.org/wiki/...
>
> > >> > >Ok, so, having no doubt read the page you just put a link up for (if
> > >> > >you have not bothered to read it, I certainly am not going to), you
> > >> > >can now explain to us **in your own words**: racially, what does
> > >> > >"white" mean?
>
> > >> > Follow the link...
>
> > >> Have you read it?    Why should I read it if you cannot be bothered
> > >> to?
>
> > >> ===========================================================================­­­==
>
> > >> I read it,
> > >> pretty interesting. it's a straightforward article and it makes no racist or
> > >> racial claims.
>
> > >In which case, it is probably not quite what Beigewolf has in mind.
>
> > On the contrary, it's why I provided you the link...  But, like your desire to
> > remain ignorant on why America is Republic and not a Democracy, you refuse to
> > follow this link and enlighten yourself on issues of race...
>
> Well enlighten me then; explain what the link says.
> Yu have read it haven't you?- Hide quoted text -
>
p.s. reason I am so suspicious is because you yourself have pointed
out how dodgy and liberal/leftwing Wikki can be so I am wary at taking
it on face value. I would like you to explain the contents please, in
your own words.