[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Using Relax NG as a grammar

Daniel Berger

12/5/2006 3:42:00 PM

Random thought of the day...

I was reading over Tim Bray's blog [1] regarding Relax NG and looking
over an example of it from wikipedia [2] and I thought to myself,
"Self, couldn't you use this for a language specification? Say, for
Ruby even?"

Thoughts? Beyond, "XML is evil!" or "Use YAML instead!", I mean.

- Dan

[1] http://www.tbray.org/ongoing/When/200x/2006/11/27/Ch...
[2] http://en.wikipedia.org/wik...

9 Answers

James Britt

12/5/2006 5:19:00 PM

0

Daniel Berger wrote:
> Random thought of the day...
>
> I was reading over Tim Bray's blog [1] regarding Relax NG and looking
> over an example of it from wikipedia [2] and I thought to myself,
> "Self, couldn't you use this for a language specification? Say, for
> Ruby even?"

Do you mean instead of BNF, for example?



--
James Britt

http://www.... - Hacking in the Desert
http://www.jame... - Playing with Better Toys

!! http://barcamp.org/BarC... 9 Dec 2006 !!

Vidar Hokstad

12/5/2006 5:56:00 PM

0


Daniel Berger wrote:
> Random thought of the day...
>
> I was reading over Tim Bray's blog [1] regarding Relax NG and looking
> over an example of it from wikipedia [2] and I thought to myself,
> "Self, couldn't you use this for a language specification? Say, for
> Ruby even?"

It _is_ meant to be used for language specification, so that's why it
looks suitable. It's only that it's meant for specifying grammars for
languages using XML syntax, and so it's (rightly) very limited in terms
of tokenization etc. which makes it unsuitable for more general
languages like Ruby.

Vidar

Daniel Berger

12/6/2006 2:02:00 AM

0

James Britt wrote:
> Daniel Berger wrote:
>> Random thought of the day...
>>
>> I was reading over Tim Bray's blog [1] regarding Relax NG and looking
>> over an example of it from wikipedia [2] and I thought to myself,
>> "Self, couldn't you use this for a language specification? Say, for
>> Ruby even?"
>
> Do you mean instead of BNF, for example?

Yes.

- Dan


Dido Sevilla

12/6/2006 11:31:00 AM

0

On 12/6/06, Vidar Hokstad <vidar.hokstad@gmail.com> wrote:
> It _is_ meant to be used for language specification, so that's why it
> looks suitable. It's only that it's meant for specifying grammars for
> languages using XML syntax, and so it's (rightly) very limited in terms
> of tokenization etc. which makes it unsuitable for more general
> languages like Ruby.

Ah, but after you're done tokenizing and have generated an abstract
syntax tree, what have you got? You could output the syntax tree into
Lisp S-Expressions, which are isomorphic to XML in a very real way. It
would, of course, be trivial if your source language was a Lisp
dialect. Relax-NG might be useful for defining the higher-level
semantics of a language, but the lower-level (and generally less
interesting) work of defining the syntactic details of the language
you need to do yourself.

Giles Bowkett

12/6/2006 10:11:00 PM

0

> syntax tree, what have you got? You could output the syntax tree into
> Lisp S-Expressions, which are isomorphic to XML in a very real way. It

Sorry if this is madness, but does that mean it is theoretically
possible to implement Lisp as XML?

--
Giles Bowkett
http://www.gilesg...
http://gilesbowkett.bl...
http://gilesgoatboy.bl...

James Gray

12/6/2006 10:17:00 PM

0

On Dec 6, 2006, at 4:10 PM, Giles Bowkett wrote:

>> syntax tree, what have you got? You could output the syntax tree into
>> Lisp S-Expressions, which are isomorphic to XML in a very real
>> way. It
>
> Sorry if this is madness, but does that mean it is theoretically
> possible to implement Lisp as XML?

I'm sure I will be shot for this, but that almost strikes me as a fun
Ruby Quiz...

James Edward Gray II

Daniel Finnie

12/6/2006 10:48:00 PM

0

It's already kindof been done:
http://thedailywtf.com/forums/56328/Sho...
Warning: contains some bad language.

James Edward Gray II wrote:
> On Dec 6, 2006, at 4:10 PM, Giles Bowkett wrote:
>
>>> syntax tree, what have you got? You could output the syntax tree into
>>> Lisp S-Expressions, which are isomorphic to XML in a very real way. It
>>
>> Sorry if this is madness, but does that mean it is theoretically
>> possible to implement Lisp as XML?
>
> I'm sure I will be shot for this, but that almost strikes me as a fun
> Ruby Quiz...
>
> James Edward Gray II
>
>

Giles Bowkett

12/7/2006 5:07:00 AM

0

The whole concept is bad language.

That's a great site, though.

"XSL was shown to be Turing complete shortly after it's proposal in 1999."

On 12/6/06, Daniel Finnie <danfinnie@optonline.net> wrote:
> It's already kindof been done:
> http://thedailywtf.com/forums/56328/Sho...
> Warning: contains some bad language.
>
> James Edward Gray II wrote:
> > On Dec 6, 2006, at 4:10 PM, Giles Bowkett wrote:
> >
> >>> syntax tree, what have you got? You could output the syntax tree into
> >>> Lisp S-Expressions, which are isomorphic to XML in a very real way. It
> >>
> >> Sorry if this is madness, but does that mean it is theoretically
> >> possible to implement Lisp as XML?
> >
> > I'm sure I will be shot for this, but that almost strikes me as a fun
> > Ruby Quiz...
> >
> > James Edward Gray II
> >
> >
>
>


--
Giles Bowkett
http://www.gilesg...
http://gilesbowkett.bl...
http://gilesgoatboy.bl...

Dido Sevilla

12/7/2006 8:52:00 AM

0

On 12/7/06, Giles Bowkett <gilesb@gmail.com> wrote:
> > syntax tree, what have you got? You could output the syntax tree into
> > Lisp S-Expressions, which are isomorphic to XML in a very real way. It
>
> Sorry if this is madness, but does that mean it is theoretically
> possible to implement Lisp as XML?

Yes, it is madness, and yes, unfortunately, it has been done. There's
that language called XSLT which you may remember... Frankly, I find
S-Expressions far easier to read than XML, so much so that I actually
wrote a small utility once upon a time to convert S-expression input
into XML output (and I did it mainly to make XSLT programs I once
wrote when I was experimenting with it easier to read! I don't have
the code anymore, but I remember that it wasn't difficult to do with
Ruby). There's also this little project:

http://weitz....

that generates HTML/XML from Common Lisp.