From: Marc Heiler Date: 2012-01-15T11:09:31+09:00 Subject: Help or Advice appreciated for parsing Hi, I am working on some pseudo-www language. The idea is simple - every HTML tag becomes a method call.

Would become: h4 And

Test

Would become: h4 'Test' This works ok-ish, but I am feeling that it is reaching an end here slowly. For instance, I actually no longer want to use pure Ruby to interpret all that. I would like to be able to do something like: h4 Test Optionally, Without any "" or '' Quotes at all. In other words, I think in the long run I wish to create a real little "language" and interpret this language instead (and map calls to functions on my own). Ok, this hopefully sets a little context of what I am trying to do. Now I was looking at old code of mine and I noticed something like this: e ' ' This is just a ruby string basically, nothing fancy at all. (7 years old code or something, I was not even using method calls here). Now I was thinking "Hmm, I could turn this into a method call, like: area :rect, '1,1,100,50','www.foobar.com' And this reads a little bit better. It is a bit shorter. Problem is ... it required a fixed argument listing. And it requires one to use ',' too, which I don't really like either. Then I was thinking "Hmm, why wouldn't I not treat those method calls as real objects instead? And the params would become messages. So I then thought "Let's try this:" area.shape 'rext' .coords '1,1,100,50' .href 'http://www.foobar.com' Ok, this does not work in Ruby. Even adding () won't work, the method chaining happens on String object eventually (and I would have cheated, area would be def area, so area() instead, returning a specific class that would respond to methods like shape, coords, href. I am not really sure if I am able to express what I am trying to achieve. :) I would like to create a language for the WWW, that is terse, elegant and avoids repetition. HTML is way too verbose and I would never go back to write it on my own again anyway. I am also not sure how this language should look like, either. area shape: rec coords: 1,1,100,50 href: http://www.foobar.com I think I am favouring this right now. But this would not be valid Ruby, so my question would be, basically ... how would I turn this into valid ruby? (It will always be on the same line. New line means something else happens, some other tag.) Confused right now... -- Posted via http://www.ruby-forum.com/.