Ruby parser with character ranges

Is there a parser for ruby syntax that identifies the exact ranges of
characters for each nonterminal? I need this to instrument ruby code.
Just getting line numbers is not adequate.

Thanks,
Jonathan

Jonathan Edwards wrote:

Is there a parser for ruby syntax that identifies the exact ranges of
characters for each nonterminal? I need this to instrument ruby code.
Just getting line numbers is not adequate.

irb has a lexer that is pretty easy to use. I think it only stores
the beginning location, though, but it should be easy to get the
range.

No example handy, sorry… if you can’t figure it out, I can assist,
though…

Hal

dunno if this helps, but you may find useful ripper
look at [ruby-talk: 86056] for the latest reference to it

···

il Fri, 12 Dec 2003 22:52:17 GMT, Jonathan Edwards edwards@nospam.lcs.mit.edu ha scritto::

Is there a parser for ruby syntax that identifies the exact ranges of
characters for each nonterminal? I need this to instrument ruby code.
Just getting line numbers is not adequate.

Jonathan Edwards wrote:

Is there a parser for ruby syntax that identifies the exact ranges of
characters for each nonterminal? I need this to instrument ruby code.
Just getting line numbers is not adequate.

Thanks,
Jonathan

Referring to example in www.ruby-talk.org/83656

If the token has an associated value, use length of value
or start position of following token.

Comments are followed by TkNL.

Strings end where the next token begins
(e.g. TkSPACE / TkCOMMA …)

daz

Thanks but I need a parse, not a lexical scan. I am looking for all
subexpressions, not just the tokens.

Jonathan

daz wrote:

···

Jonathan Edwards wrote:

Is there a parser for ruby syntax that identifies the exact ranges of
characters for each nonterminal? I need this to instrument ruby code.
Just getting line numbers is not adequate.

Thanks,
Jonathan

Referring to example in www.ruby-talk.org/83656

If the token has an associated value, use length of value
or start position of following token.

Comments are followed by TkNL.

Strings end where the next token begins
(e.g. TkSPACE / TkCOMMA …)

daz