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.