- A parser is a compiler or interpreter component that breaks data into smaller elements for easy translation into another language.
- A parser takes input in the form of a sequence of tokens or program instructions and usually builds a data structure in the form of a parse tree or an abstract syntax tree.
Working
The overall process of parsing involves three stages:
1. Lexical Analysis: It produces tokens from a stream of input string characters, which are broken into small components to form meaningful expressions.
2. Syntactic Analysis: Checks whether the generated tokens form a meaningful expression. This makes use of a context-free grammar that defines algorithmic procedures for components. These work to form an expression and define the particular order in which tokens must be placed.
3. Semantic Parsing: The final parsing stage in which the meaning and implications of the validated expression are determined and necessary actions are taken.
Parsers are widely used in the following technologies:
- Java and other programming languages
- HTML and XML
- Interactive data language and object definition language
- Database languages, such as SQL
- Modeling languages, such as virtual reality modeling language
- Scripting languages
- Protocols, such as HTTP and Internet remote function calls
Compiler
- A compiler is a special program that processes statements written in a particular programming language and turns them into machine language.
- Typically, a programmer writes language statements in a language one line at a time using an editor .
- The file that is created contains what are called the source statements .
- When executing (running), the compiler first parses (or analyzes) all of the language statements syntactically one after the other.
- The Java programming language, a language used in object-oriented programming, has introduced the possibility of compiling output (called bytecode ) that can run on any computer system platform.
- The Java virtual machine or bytecode interpreter is provided to convert the bytecode into instructions that can be executed by the actual hardware processor.
- Using this virtual machine, the bytecode can optionally be recompiled at the execution platform by a just-in-time compiler .
No comments:
Post a Comment