Are there any major benefits to parsing XML using antlr?

324 views
Skip to first unread message

mgcut...@gmail.com

unread,
Mar 4, 2013, 12:31:24 PM3/4/13
to antlr-di...@googlegroups.com
I understand the use of Antlr in parsing things like SQL, Java or some custom language, however I am not sure about the benefits about parsing something like XML.

It seems like it would be easier to do it with Antlr, however XML is already a well defined document structure with XSD that can validate the structure of the XML. It would seem that if you already have something that parses XML, using Antlr does not gain you much. I am new to Antlr so I may be completely missing something.

Mike Lischke

unread,
Mar 4, 2013, 12:55:16 PM3/4/13
to antlr-di...@googlegroups.com

> I understand the use of Antlr in parsing things like SQL, Java or some custom language, however I am not sure about the benefits about parsing something like XML.
>
> It seems like it would be easier to do it with Antlr, however XML is already a well defined document structure with XSD that can validate the structure of the XML. It would seem that if you already have something that parses XML, using Antlr does not gain you much. I am new to Antlr so I may be completely missing something.


XML is not a language with a fixed alphabet. You can define new tag types as you see need. This cannot be modeled by a parser generator which works with a limited set of input tokens.

Additionally, the general structure of XML is well defined and simple and consists of simple elements. It's certainly easier to just read from the opening to the closing tag interpreting attributes and content recursively. ANTLR would certainly be oversized for such a simple task.

Mike
--
www.soft-gems.net

Terence Parr

unread,
Mar 4, 2013, 6:17:48 PM3/4/13
to antlr-di...@googlegroups.com
You can use ANTLR for a nice lexer and parser but w/o treating the tags as keywords.
Ter
----------[from the book]--------------



--
www.soft-gems.net

--
You received this message because you are subscribed to the Google Groups "antlr-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to antlr-discussi...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.





--
Dictation in use. Please excuse homophones, malapropism, and nonsense. 
XMLLexer.g4
XMLParser.g4
Reply all
Reply to author
Forward
0 new messages