From: Andrew Green Date: 2007-04-25T02:06:07+09:00 Subject: Re: Arrow operator with dash instead of equals (->) El mi�, 25-04-2007 a las 00:04 +0900, Martin DeMello escribi�: > Rather than leaving the |{}| blocks entirely alone, you could > preprocess them to change the -> to something ruby will accept, and > then run the interpreter over the preprocessed string. Won't be a > trivial task, but should be easier than any of the alternatives. El mar, 24-04-2007 a las 17:48 +0900, Brian Candler escribi�: > 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. OK. Everything seems to indicate this is the way to go, in the long-to-medium term. Thanks, Brian, Martin and everyone else, for all your help. Andrew