Parse

Parsing is the process of decoding information from a source into a more usable format.

A simple, non-technical example would be browsing this webpage. When the page loads you start to scan the page to understand the subject of the page, how the content is organized, how you can navigate the site, and how you can achieve your goal on that page. After scanning the page you have a mental model for how to interact with the page. You could now say “I’ve parsed the webpage!”

Continuing in the webpage context, in order to render this page on in your browser, the browser must parse the page’s HTML. This is a common use for the term “parsing.” When a browser requests an HTML (or XML) document it must read the HTML text and decode the HTML tags so that the browser has the information a format that can use to render the page.

According to Mozilla, "The browser parses HTML into a DOM tree. HTML parsing involves tokenization and tree construction. HTML tokens include start and end tags, as well as attribute names and values. If the document is well-formed, parsing it is straightforward and faster. The parser parses tokenized input into the document, building up the document tree.”

As the browser is parsing HTML, it also must parse the CSS so the CSS rules can be applied to the page’s DOM model so the browser can “paint” the content to the screen.

Finally, there is one more common use for the term “parse” when it comes to programming and that is when programming languages themselves must be parsed as a step toward execution.

Take this human example: when you hear the instructions, “go to the market and buy some bread,” you must first decode all the words, their meanings, and the sentence’s order before you can understand the instruction, and thus act on it, computers do the same with code.

In Python, for example, the computer must parse the code before it compiles it in order to execute the instructions.