1

I heard somewhere that XML is a language for abstract syntax. Now here I don't understand is that how XML can be used to specify the abstract syntax or structure or systems.

Can anybody please help me with this concept.?

Thank you

  • 1
    Have you ever heard of a 'parse tree'? If not, look it up - Since XML has a tree structure it can represent one of those, meaning it can represent parsed syntax. – Patashu May 15 '13 at 02:25
  • You can encode ASTs in XML, as Patashu has noted. See http://stackoverflow.com/a/15992608/120163 for an example AST encoded this way. BUT... don't confuse XML for THE ONLY way to encode ASTs; see http://stackoverflow.com/a/6378997/120163 for a LISP-like alternative. Also, don't confuse XML for a *good* way to encode ASTs; it is rather bulky and the AST for real programs encoded as XML is rather big and clunky. – Ira Baxter May 31 '13 at 02:45

1 Answers1

1

How about this for the abstract syntax of an arithmetic expression:

<multiply>
  <number>2</number>
  <add>
    <number>3</number>
    <number>4</number>
  </add>
</multiply>

I don't know if that's what you had in mind, but if it isn't, perhaps it will help you to clarify your question.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164