Parser

What Does Parser Mean?

A parser is the part of a compiler that breaks source code into small sections of character strings called tokens.

Advertisements

The term has its roots in linguistics. In linguistics, parsing involves physically diagraming the underlying structure of a sentence. The purpose is to help the learner understand the context of each sentence element and its relationship to the meaning of the sentence.

In computing, parsers create logical diagrams called trees. The purpose is to help the compiler understand the context of each token and its relationship to the underlying structure of the source code.

Parsers are widely used in the following technologies:

  • Java and other programming languages.

  • HTML and XML.

  • Database languages such as SQL.

  • Modeling languages, such as virtual reality modeling language (VRML).

  • Scripting languages such as Javascript.

  • Protocols, such as HTTP.

Techopedia Explains Parser

The technical process of parsing has three stages:

  1. Lexical Analysis: produces tokens from a stream of input characters. A token is the smallest unit in a programming language that possesses some meaning (such as +, -, *, “function”, or “new” in JavaScript).

  2. Syntactic Analysis: checks to see if the generated tokens form a meaningful expression.

  3. Semantic Parsing: uses syntax trees and symbol look-up tables to determine whether the generated tokens are semantically consistent with a specific programming language.

Parsing can be conducted in either a top-down or bottom-up manner.

  • Top-Down Parsing: Parsing begins with the start symbol and trees are built from root to leaves. Top-down parsing is also called predictive parsing or recursive parsing.

  • Bottom-Up Parsing: Trees are built from leaves to root and ends with the start symbol. This type of parsing is also known as shift-reduce parsing.

Advertisements

Related Terms

Latest Computer Science Terms

Related Reading

Margaret Rouse

Margaret Rouse is an award-winning technical writer and teacher known for her ability to explain complex technical subjects to a non-technical, business audience. Over the past twenty years her explanations have appeared on TechTarget websites and she's been cited as an authority in articles by the New York Times, Time Magazine, USA Today, ZDNet, PC Magazine and Discovery Magazine.Margaret's idea of a fun day is helping IT and business professionals learn to speak each other’s highly specialized languages. If you have a suggestion for a new definition or how to improve a technical explanation, please email Margaret or contact her…