Where can I find eval rules for ruby?

Can anyone point me to a specification on Ruby's evaluation rules?

I am trying to understand Domain Specific Language implementation in Ruby,
there are lot of examples such as
http://www.infoq.com/articles/eval-options-in-ruby, but I can't find a
definitive guide on the interpreters rule for evaluating a line of DSL
String in instance_eval call.

thanks for your help

daryoush

Daryoush Mehrtash wrote:

I am trying to understand Domain Specific Language implementation in Ruby,
there are lot of examples such as
http://www.infoq.com/articles/eval-options-in-ruby, but I can't find a
definitive guide on the interpreters rule for evaluating a line of DSL
String in instance_eval call.

DSL is a state of mind, not a language inside a string inside a language.

The state of mind is that you intend to write in one language style,
inside another language. For example, Rake is a _light_ form of rule
solver, so you can write it in a format paralleling a Makefile:

  task :rule_1 => [:rule_2, :rule_C] do
     evaluate_rule_1
  end

To write in a declarative mode, write object methods with store their
commands in an engine, and then process the engine. Here's a little
Flea script to draw a spiral:

egg = startOvum(18, 45, 100)
ax = egg.newRootAxiom('A')
b = egg.newAxiom('B')

ax.longer(6).right.color(1).gosub(b)
b.tube.shorter(0.8).left.link(b)
render egg

The commands like longer, right, color, etc are turtle graphics
describing a shape. render then outputs the shape.

All the ActiveRecord association commands - has_many, belongs_to, etc
- qualify as DSLs too. The goal is to give your user-programmer a
clear but deep interface, so they can write the command they need, in
the relevant context they need, and the engine on the inside hides the
complexity.

···

--
Phlip
http://www.oreilly.com/catalog/9780596510657/
^ assert_xpath
http://tinyurl.com/yrc77g <-- assert_latest Model

This is exactly the issue I am trying to understand:

To write in a declarative mode, write object methods with store their

commands in an engine, and then process the engine.

I need to understand the object methods I would need to support the
evaluation, and the sequence of calls.

For example, let say I create and object instance and instance_eval
the following:

if the '$1-$2 No Limit' list is more than 15 then notify the floor to open

this seems to result in
(than 15)
(more (than 15))
(is (more (than 15))) ...

What I am looking for is the rule that the ruby interpreter uses to evaluate
a given script.

daryoush

···

On 8/15/07, Phlip <phlip2005@gmail.com> wrote:

Daryoush Mehrtash wrote:

> I am trying to understand Domain Specific Language implementation in
Ruby,
> there are lot of examples such as
> http://www.infoq.com/articles/eval-options-in-ruby, but I can't find a
> definitive guide on the interpreters rule for evaluating a line of DSL
> String in instance_eval call.

DSL is a state of mind, not a language inside a string inside a language.

The state of mind is that you intend to write in one language style,
inside another language. For example, Rake is a _light_ form of rule
solver, so you can write it in a format paralleling a Makefile:

  task :rule_1 => [:rule_2, :rule_C] do
     evaluate_rule_1
  end

To write in a declarative mode, write object methods with store their
commands in an engine, and then process the engine. Here's a little
Flea script to draw a spiral:

egg = startOvum(18, 45, 100)
ax = egg.newRootAxiom('A')
b = egg.newAxiom('B')

ax.longer(6).right.color(1).gosub(b)
b.tube.shorter(0.8).left.link(b)
render egg

The commands like longer, right, color, etc are turtle graphics
describing a shape. render then outputs the shape.

All the ActiveRecord association commands - has_many, belongs_to, etc
- qualify as DSLs too. The goal is to give your user-programmer a
clear but deep interface, so they can write the command they need, in
the relevant context they need, and the engine on the inside hides the
complexity.

--
Phlip
http://www.oreilly.com/catalog/9780596510657/
^ assert_xpath
http://tinyurl.com/yrc77g <-- assert_latest Model

--
Daryoush

Weblog: http://perlustration.blogspot.com/