The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
The Neo-Rails controversy and a language generator

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Eigen Class

Posts: 358
Nickname: eigenclass
Registered: Oct, 2005

Eigenclass is a hardcore Ruby blog.
The Neo-Rails controversy and a language generator Posted: Mar 29, 2007 8:06 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Eigen Class.
Original Post: The Neo-Rails controversy and a language generator
Feed Title: Eigenclass
Feed URL: http://feeds.feedburner.com/eigenclass
Feed Description: Ruby stuff --- trying to stay away from triviality.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Eigen Class
Latest Posts From Eigenclass

Advertisement

There's seemingly no end to the drivel coming from these Neo-Rails sects, or is it people pretending to be Java supporters posing as Railers?

Summing up, lgenerator.rb.

Here's a simple example (see the PostRailsMonkey Manifesto for a complex one):

require 'lgenerator'
gen = Generator.new do |g|
  # default non-terminal is main, can be set with    start :whatever
  main.is :hello, "\n", :ex1, "\n", :ex2
  hello.is "Hello, ", :somebody, "!"
  somebody.is "matz" | "world"     # basic disjunction

  ex1.is "This is a more ", ("complex " | "elaborate "), :example, "."
  example.is "example" | "test"

  ex2.define do
    is "Some simple sentence."
    is "Another, involving ", ["a more complex ", :exp] | "harder stuff ", "."
    is "Yet another possibility; each one is chosen with prob. 1/3."
  end
 
  exp.is "expression" | "disjunction" | :example
end

puts gen.generate

#>> Hello, world!
#>> This is a more elaborate test.
#>> Yet another possibility; each one is chosen with prob. 1/3.

The language generator can handle recursive derivations and perform actions when a rule is followed. You can for instance make it remember the choice for a particular derivation and use it in another:


Read more...

Read: The Neo-Rails controversy and a language generator

Topic: Rails on 1.9: first benchmarks, YARV exposed to non-synthetic tests Previous Topic   Next Topic Topic: Losing faith in the human race


Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2017 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us