Using Relax NG as a grammar

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/Choose-Relax
[2] http://en.wikipedia.org/wiki/RELAX_NG

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.rubyaz.org - Hacking in the Desert
http://www.jamesbritt.com - Playing with Better Toys

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

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

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

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.

···

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.

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.gilesgoatboy.org

http://gilesgoatboy.blogspot.com

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

James Edward Gray II

···

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?

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.de/cl-who/

that generates HTML/XML from Common Lisp.

···

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?

It's already kindof been done:
http://thedailywtf.com/forums/56328/ShowPost.aspx
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

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:
404 - Not Found
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.gilesgoatboy.org

http://gilesgoatboy.blogspot.com