[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 6:26:00 PM

That is similar to what I'm doing. A primary difference
between what you are doing and I am is that for yours a rule is
a proc/method and for mine a rule is an object. I think the
way I did it is cleaner, but having a rule as a proc does make
it easier to have local variables in a rule. I have to pass
variables in a rule around in the parse tree (preferred) or via
globals (yuck).

The samples you show parse strings. Can you parse files
without reading the whole thing in? Can you do things with or
without a lexer? The way I have it set up a lexer is optional
and a lexer can be built out of the same parse classes.

We could collaborate off-line if you wish...

Eric

--- Takaaki Tateishi <ttate@ttsky.net> wrote:
> Eric Mahurin wrote:
> > Here is my first contribution to Ruby:
> > http://raa.ruby-lang.org/proje...
>
> Let me inform you that I'm also developing similar library
> TDP4R. :-)
> http://rubyforge.org/proj...
> Some examples are available at:
>
>
http://rubyforge.org/cgi-bin/viewcvs.cgi/tdp4r/samples/?cvs...
>
> Thanks,
> --
> Takaaki Tateishi <ttate@ttsky.net>
>
>
>



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


2 Answers

Takaaki Tateishi

4/18/2005 3:06:00 PM

0

Eric Mahurin wrote:
> That is similar to what I'm doing. A primary difference
> between what you are doing and I am is that for yours a rule is
> a proc/method and for mine a rule is an object. I think the
> way I did it is cleaner, but having a rule as a proc does make
> it easier to have local variables in a rule.

A rule of tdp4r is an instance of Rule, which consists of Proc objects and methods.
In order to handle a recursive rule easily, tdp4r uses methods.

> The samples you show parse strings. Can you parse files
> without reading the whole thing in?

It's possible if you define methods shift and unshift.
A parser read a token using shift and push it back using unshift.

> Can you do things with or without a lexer?

tdp4r doesn't provide a function of a lexer.

Thanks,
--
Takaaki Tateishi <ttate@ttsky.net>



Takaaki Tateishi

4/18/2005 9:40:00 PM

0

Takaaki Tateishi wrote:
> It's possible if you define methods shift and unshift.
> A parser read a token using shift and push it back using unshift.

Sorry, that is not correct.
--
Takaaki Tateishi <ttate@ttsky.net>