1. anlr version problems.
The anlr version used during development is updated shortly later. It is not compatible with earlier versions (including those used in projects) and the syntax files in the project cannot be used in the current anlr version.
The uploaded project contains the currently used anlr runtime dll file (which should be 3.0.1), and the Code contains the generated lexer and parser cs files. However, if you want to regenerate lexer and parser from the. g syntax file, you have to use the corresponding anlr java package. I have no more options. You can check whether the anlr website provides download.
2. Implementation is messy.
This was written in the past few years for project development. The development of this item is not within the Project Plan. Therefore, it takes only a week to get out of anlr and the code, later, it was just a little bit of bug change, and there was no structural adjustment, so it really had no reference effect.
The main idea is very simple. You can generate AST using anlr and traverse AST to generate SQL using the visitor mode. The visitor interface is designed to facilitate ORM ing. However, due to the rush of time, you have no in-depth understanding of anlr, and the code implementation and syntax files can only be described in one word: Chaos. I was planning to study anlr and sort out the project, but I was always lazy.
Looking at HQL parsing of nhib.pdf in the first two weeks, his structure is much better. We suggest you really want to know how to use anlr as an SQL parser. Please refer to nhib.pdf or hibernate.
Because some people often send messages and want to learn, please download the anlr SQL parser code here.
1. Set the output type to the windows application form, which contains a form to test the parsing effect.
2. Only standard select query statements are supported.