Category: 

What is a Parser?

Article Details
  • Written By: Derek Schauland
  • Edited By: O. Wallace
  • Last Modified Date: 20 September 2014
  • Copyright Protected:
    2003-2014
    Conjecture Corporation
  • Print this Article
Free Widgets for your Site/Blog
A walnut can be used to remove furniture scratches.  more...

October 1 ,  1890 :  Yosemite National Park was established.  more...

A parser is a piece of software that evaluates the syntax of a script when it is executed on a web server. For scripting languages used on the web, the parser works like a compiler might work in other types of application development environments.

In the same way a compiler can create object code to be used on a computer from source code, a parser can turn scripted code into readable object code or display syntax errors found when the code is executed in a browser.

Parsers are commonly used in script development because they can evaluate code when the script is executed and do not require that the code be compiled first. The compilation of source code and its execution happens all in one step as opposed to a C++ or other binary compiler in which the source code is compiled into object code and then this code must be installed or run separately.

The biggest difference between a parser and compiler is the environment and language which they deal with. For example, many scripts are parsed by the server, and application or operating system source code is compiled for installation. The two terms can be used interchangeably to represent the same activity, and application code can be parsed into object code and script code compiled on the web.

Ad

Many parsers work sequentially in that they execute the submitted statements from left to right and top to bottom. When an error is found, the parser will stop. If coding for an error condition exists in the application, the actions related to that coding are taken. If the parsed code is a script on the web, the error may be displayed to the browser window as the code is executed. A parser cannot handle code at line 12 if the code at line 11 or earlier is causing an error.

The parser evaluates the submitted syntax (or code) and determines the executable parts, displaying found errors as it goes along. This aides in the debugging of code and can help protect intellectual property that may be the source code of the project. An example of this process does not have to be thought of in terms of scripting or programming. Think of a sentence in the English language. The following sentence will do nicely:

The big brown bear runs fast.

To parse this sentence would be to dissect the properties of the words in the sentence so that the reader would understand that bear is a noun, brown and big are adjectives which describes the bear and that runs is the verb or action that the bear performs. The adverb fast modifies the verb runs in the sentence.

That is a simple example of what a parser does. It evaluates the code provided for syntax and can create object code or usable output.

Ad

More from Wisegeek

You might also Like

Discuss this Article

Post your comments

Post Anonymously

Login

username
password
forgot password?

Register

username
password
confirm
email