Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Parsing ruby-code with the ruby-interpreter itself

Reply
Thread Tools

Parsing ruby-code with the ruby-interpreter itself

 
 
cies
Guest
Posts: n/a
 
      10-24-2006
at the moment most code editors are using sets of regexps, and other
difficult stuff to do highlighting and syntax error checking...

i was (naturally) thinking: why?

ruby already contains a nice parser for parsing ruby!
would it be possible to build hooks into the ruby-interpreter for code-editors?

i was thinking a small interface exposed by a (both c and ruby)
library, that allows other programs (mainly code editors for as far as
i can imagine) to make use of the relatively fast, and standard
compliant ruby parser that is already in ruby...

searching the net i found nothing that does this. yet i might have
searched in the wrong direction.

well, i'm not a good C coder, i tried to look at ruby's internals to
figure to find out if i could make a patch... but no; i can't, i got
too dizzy

am i suggesting a small layer over the parse.{c,y} and lex.c, or am
suggesting a much bigger project?


thanks for reading all the way up to the end,
cies breijs.


--
"Computer games don't affect kids; I mean if Pac-Man affected us as
kids, we'd all be running around in darkened rooms, munching magic
pills and listening to repetitive electronic music." -- Kristian
Wilson (Nintendo, Inc), 1989

 
Reply With Quote
 
 
 
 
Dominik Bathon
Guest
Posts: n/a
 
      10-24-2006
On Tue, 24 Oct 2006 13:23:47 +0200, cies <(E-Mail Removed)> wrote:

> at the moment most code editors are using sets of regexps, and other
> difficult stuff to do highlighting and syntax error checking...
>
> i was (naturally) thinking: why?
>
> ruby already contains a nice parser for parsing ruby!
> would it be possible to build hooks into the ruby-interpreter for
> code-editors?
>
> i was thinking a small interface exposed by a (both c and ruby)
> library, that allows other programs (mainly code editors for as far as
> i can imagine) to make use of the relatively fast, and standard
> compliant ruby parser that is already in ruby...
>
> searching the net i found nothing that does this. yet i might have
> searched in the wrong direction.


There are multiple libraries that do things like that:

First there is Ripper. It works by putting its own hooks into parse.y and
then providing a SAX-like interface. I am not sure about its status and
how complete it is.

Then there are RubyNode and ParseTree, which wrap Ruby's internal NODEs.
They can both take a string, parse it using Ruby's parser (without
executing it) and then return the resulting NODE tree. The downside of
this approach is that comments are ignored, because they are not
represented in the NODE tree, otherwise it works quite good.

Dominik

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
obtain element name, or attribute and value of the document name itself, and some elemnts and attributes from an ancestor or the node itself using xquery Jeff Kish XML 4 10-30-2008 05:47 PM
[ANN] Parsing Tutorial and YARD 1.0: A C++ Parsing Framework Christopher Diggins C++ 0 07-09-2007 09:01 PM
[ANN] Parsing Tutorial and YARD 1.0: A C++ Parsing Framework Christopher Diggins C++ 0 07-09-2007 08:58 PM
SAX Parsing - Weird results when parsing content between tags. Naren XML 0 05-11-2004 07:25 PM
Perl expression for parsing CSV (ignoring parsing commas when in double quotes) GIMME Perl 2 02-11-2004 05:40 PM



Advertisments