Lexical analyzer ANTLR

Source: Internet
Author: User

  First, we all know that the programming language needs to be compiled before it executes, so that the code can be converted into a machine-recognized language, and this process is compiled.

So how does it compile?

Java is compiled in the JVM virtual machine, and JavaScript is compiled in the JS engine.

The process of compiling is generally three steps:

1. Word Segmentation/Lexical analysis (tokenizing/lexing)

This process will break down the string into chunks of code that are meaningful (for programming languages) that are called lexical units (tokens).

2. Analytic/syntactic analysis (parsing)

The process is to transform the lexical unit stream (array) into a tree that represents the syntactic structure of the program, composed of elements that are nested hierarchically. This tree is called the abstract syntax tree.

3. Code generation

The process of converting an AST to executable code is called code generation. This process is related to language, target platform and other information.

Second, ANTLR is a powerful language recognition tool based on Java development, ANTLR with its introduction of the syntax and high-speed operating efficiency in such tools to Excel.

In ANTLR, the lexical Analyzer (Lexer), the parser (Parser), and the tree Parser are automatically generated by parsing user-defined context-independent grammars.

Source: "JavaScript you Don't Know", IBM Chinese Community http://www.ibm.com/developerworks/cn/java/j-lo-antlr/

Lexical analyzer ANTLR

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.