Anlr application scenarios

Source: Internet
Author: User

Anlr is a language identification tool implemented in Java. It defines a structure file to identify the target language, and then uses its tool to generate the file into a Java code that can be parsed into the target language, the generated code can be used to parse the target language. This method avoids writing Java code to parse text. You can use anlr to parse JSON, HTML, XML, EDIFACT, or custom message formats. The parsed information can also be defined in the structure file. The following describes how to define the target language element:

String with double quotation marks: String: '"' ('\"' | ~ ('"'))*'"'

Underline: ID: 'A'... 'Z' | '0'... '9' | '_'

Get parsed content: S = ID + {system. Out. println ($ S. Text );}

S contains one or more letters and numbers. When the target string meets this condition, you can obtain the actual content in the target from $ S. Text.

The anlr structure defines a lot of content. For the specific syntax format and usage, see the http://www.antlr.org/or book: the definitive guide anlr reference

Anlr can be used to design specific domain languages (DSL). Similar to hql in hibernate, DSL can be used to define high-level syntaxes for operations to be executed. This syntax is close to what people can understand, translation from DSL to computer language is done through anlr. You can define the specific operations of dsl commands in the anlr structure language.

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.