What is parsing?

Grace picture Grace · Nov 24, 2009 · Viewed 83.7k times · Source

Parsing is something I come across a lot in development, but as a junior it is one of those things I assume I will get the hang of at some point, when it is needed. In my current project I've been told to find and use an HTML parser for a certain function, I have found a couple on the web.

But what does an HTML parser actually do? And what does it mean to parse an object?

Answer

Jon Skeet picture Jon Skeet · Nov 24, 2009

Parsing usually applies to text - the act of reading text and converting it into a more useful in-memory format, "understanding" what it means to some extent. So for example, an XML parser will take the sequence of characters (or bytes) and convert them into elements, attributes etc.

In some cases (particularly compilers) there's a separation between lexical analysis and syntactic analysis, so the real "understanding" part of the parser works on a sequence of tokens (identifiers, operators etc) rather than on the raw characters.