By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,652 Members | 1,698 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,652 IT Pros & Developers. It's quick & easy.

Any XML standards for code grammar?

P: n/a
I am written a program that will be used to parse the lexical syntax of code
files. I would like to generalize the grammar logic so that I don't
hardcode any specific grammar in my program. Basically I would like to use
XML to define a languages grammar the way that BNF does. Are there any
standard XML format for defining a languages grammar?


Nov 11 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Any chance you can express the grammar as a schema? There are several
competing schema standards, XML Schema (also referred to as XSD) seems to be
the more popular one, but maybe others (DTD, Schematron, Relax-NG) may suit
your needs better.

--
HTH
Christoph Schittko [MVP]
Software Architect, .NET Mentor

"Peter Rilling" <pe***@nospam.rilling.net> wrote in message
news:Ot**************@TK2MSFTNGP12.phx.gbl...
I am written a program that will be used to parse the lexical syntax of code files. I would like to generalize the grammar logic so that I don't
hardcode any specific grammar in my program. Basically I would like to use XML to define a languages grammar the way that BNF does. Are there any
standard XML format for defining a languages grammar?

Nov 11 '05 #2

P: n/a
You misunderstand.

Similar to the way that different industries have developed XML structures
for their needs (e.g. VoiceXML, MathXML, etc.) I was wondering if the
software industry any standard way to represent BNF form in XML.

It is much easier to parse an XML file than it is to parse a text file.

For instance, I would like to have a system that reads something like the
following:
<statement name="x">
<statement name="inner">
<token value="somevalue"/>
...

which in BNF would look something like:
x ::= <inner>
inner ::= somevalue
....

I want to be able to express the computer language's grammar in XML format
rather than BNF. Before I attempted to define the XML structure that I
would use, I was hoping that there were already proposed standards for this.

"Christoph Schittko [MVP]" <ch********************@austin.rr.com> wrote in
message news:uv**************@TK2MSFTNGP12.phx.gbl...
Any chance you can express the grammar as a schema? There are several
competing schema standards, XML Schema (also referred to as XSD) seems to be the more popular one, but maybe others (DTD, Schematron, Relax-NG) may suit your needs better.

--
HTH
Christoph Schittko [MVP]
Software Architect, .NET Mentor

"Peter Rilling" <pe***@nospam.rilling.net> wrote in message
news:Ot**************@TK2MSFTNGP12.phx.gbl...
I am written a program that will be used to parse the lexical syntax of

code
files. I would like to generalize the grammar logic so that I don't
hardcode any specific grammar in my program. Basically I would like to

use
XML to define a languages grammar the way that BNF does. Are there any
standard XML format for defining a languages grammar?


Nov 11 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.