From: Brian Candler Date: 2007-04-24T17:48:07+09:00 Subject: Re: Arrow operator with dash instead of equals (->) On Tue, Apr 24, 2007 at 06:52:14AM +0900, Andrew Green wrote: > Anyway, all of this is processed by our own interpreter, including, for > example, the rule > > has_parent->place_of_birth > > As you can see it's mainly declarative. However this part > > |{ (ROOT->has_given_names).textBPV + " " + (ROOT->has_last_names).textBPV }| > > is read by our interpreter only as a string between a |{ and a }| . > > That string is then passed to the Ruby interpreter and is meant to be > run (from within a specific context that our interpreter determines). In > these bits we don't want just our language running about, of course, we > want full-blown Ruby code with extensions that allow a programmer to > refer to the graph traversal rules using a syntax similar to that used > in the rule definitions that appear _outside_ the Ruby code blocks. And my suggestion still stands: if what you want to appear inside {..} is a language which has -> as an operator, then a 'clean' (albeit heavyweight) option is to write your own expression parser using an LALR parser generator. The expression parser can build a syntax tree, and then you can either walk this tree yourself, or use it to generate Ruby code as its output, which you can then run. A completely different option would be to use Perl instead of Ruby, since Perl has a -> dereference operator. But then you will have to put lots of dollar signs and curly brackets in. B.