Introduction to ANTLR (another tool for language recognition) [Translation]

zhaozj2021-02-11  191

Introduction to ANTLR

Tenz Par

Introduction

In the 1980s, I managed many of the language identification procedures and translation procedures. In the end, I became very annoying, so that I started to automate this process; thus generated my motto:

"You can use the five years of life to make it automatically, why do you have to perform in five days."

The advantage of manually constructing such a multi-project is that you can understand their commonality and hope that those work can be reasonably formified and automated. However, I don't understand YACC very well, but in any case, I want something, it can regenerate my hand-created program. Anltr is this result (actually called PCCTS). I have been working hard for more than ten years. [See fast history, you can get more details].

Another tool for ANTLR, namely language recognition. It is such a tool that can accept the textual language description and can generate a program that identifies the statement of these languages. As part of the translation program, you can use simple operators and movements to parameterize your grammat, so that how to create an abstract syntax tree (AST) and how to generate output. ANTLR knows how to generate an identification program, language includes Java, C , C #, and short-lasting Python.

ANTLR knows how to build an identification program that applies a grammar structure for the following three different inputs: (i) character stream, (ii) marker stream, and (iii) two-dimensional tree structure. Naturally, they match the lexers (Lexers, hereinafter referred to as Lexer), language parsing programs, and tree access. This is used to define the meta-language of these syntax, almost the same in all cases.

Once you are more written about Antlr and similar tools, you will start programming with a new look. Many tasks strongly need language solutions, rather than adopting traditional programming languages. For example, the annotations of these processes are written in Terence markers. Since I hate html, I use ANTLR to write a very small translator to convert text (contain additional things and conversions) into HTML, PDF or other files I bored to write to generate programs. format.

Finally, I want to point out that Antlr is just a tool, just these. Although it can help you create software by bringing the boring part of the easily understand, but you can't try to make you specify the entire compiler. For example, it will not work in a single description. Those who claim that this kind of thing is very great, can prepare an amazing "package solution" for the release of the publication article, but will tragic failure in the actual project.

Since 2003, there are nearly 5,000 Anltr downloads per month. ANTLR is fully open, and there is no copyright and has a complete source code.

These words assume that you are familiar with basic identification and translation. From now on, you need to be familiar with Anltr's meta language and what it produces. Later, we will focus on creating a complex translation program.

转载请注明原文地址:https://www.9cbs.com/read-5883.html

New Post(0)