Using Relax NG as a grammar

J

James Britt

Daniel said:
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 !!
 
V

Vidar Hokstad

Daniel said:
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
 
D

Daniel Berger

James said:
Daniel said:
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
 
D

Dido Sevilla

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.
 
G

Giles Bowkett

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?
 
J

James Edward Gray II

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
 
G

Giles Bowkett

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."
 
D

Dido Sevilla

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top