Skip to main content

A parser o parser (comes from English: parse - go through a string or text in logical syntactic components) is a program that is normally part of a compiler. The compiler makes sure that the code is correctly translated into an executable language. The task of the parser is, for this case, the decomposition and transformation of the inputs into a usable format for further processing. A string of instructions is parsed in a programming language and then decomposed into its individual components.

How does it work

To review text, parsers often use a separate lexer (called a lexer), which breaks the input data into tabs (input symbols as words). Lexers are generally finite machines, following the regular grammar and thus promising a proper breakdown. The tokens thus obtained serve as input characters for the parser.

The current parser handles the grammar of the input data, performs a syntactic analysis of these and as a general rule creates a syntax tree (parse tree). This can be used for post-processing of the data, for example, code generation by a compiler or executed by an interpreter (translator). Thus, the parser is the software that checks, processes, and forwards the source code instructions.

Syntactic Analyzer-en-01.png

Example of a parse tree

Types of analyzers

There are simply two different analysis methods, top-down analysis and bottom-up analysis. These generally differ in the order in which the items in the syntax tree are created.

  • From top to bottom: In the top-down method, the parser works on a method goal-oriented, which means that it searches from the start symbol of the syntax and looks for a suitable syntactic derivation. In this way, the parse tree develops from top to bottom in the direction of an increasingly detailed breakdown.
  • Bottom up: The bottom-up parser starts with the symbol of the input string and tries to determine increasing syntactic relationships. This is done until the start symbol of the grammar has been reached.

Apps

A parser is commonly used to convert text into a new structure, for example a syntax tree, which expresses the hierarchical arrangement of items. In the following apps the use of an analyzer is usually essential:

  • Reading a programming language is done by a parser. It provides a data structure to the compiler, with which the machine code or bytecode can be generated.
  • The HTML code is initially just a character string for a PC that must be parsed by the parser contained in the web browser. Provides a description of the web page as a data structure that can be projected by a layout engine on the screen.
  • Special XML parsers are responsible for parsing XML documents and prepare the information contained in them for later use.
  • URI parsers decompose complex schemes such as URLs into their hierarchical structure.
  • Search engines like Google extract (analyze) text relevant to them from downloaded web pages with crawlers. They are processed and the analyzed data can be used for navigation.

conclusion

There are more classifications of parser types at the same time from the explained subdivision in top-down and bottom-up analysis. Based on the parsed grammar, better crawls can be performed on web pages with the appropriate parser. Search engines will always try to take full advantage of this efficient web analysis procedure to provide the user with fast and informative search results.

Web Links

R Marketing Digital